package com.milk.service.demo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.dubbo.annotation.DubboService;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import com.milk.service.DemoService;

@Service
@DubboService(interfaceClass = DemoService.class)
public class DemoServiceImpl implements DemoService {
	
	private Logger log = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
	private StringRedisTemplate stringRedisTemplate;

	public String sayHello() {
		// TODO Auto-generated method stub
		try {
			Thread.sleep(10000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		String oldValue = stringRedisTemplate.opsForValue().get("hello");
		if("开始".equals(oldValue))
		{
			log.info("service v2 sayHello is running!");
			stringRedisTemplate.opsForValue().set("hello", "成功");
			
		}else if("失败".equals(oldValue)){
			log.info("service v2 sayHello is cancel!");
		}
		
		
		return "hello world";
	}

}
